<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="'SNMP' | translate"
  [loading]="isFormLoading()"
></ix-modal-header>

<mat-card class="card">
  <mat-card-content>
    <form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
      <div class="columns">
        <ix-fieldset [title]="'General Options' | translate">
          <ix-input
            formControlName="location"
            [label]="'Location' | translate"
            [tooltip]="tooltips.location | translate"
          ></ix-input>

          <ix-input
            formControlName="contact"
            type="email"
            [label]="'Contact' | translate"
            [tooltip]="tooltips.contact | translate"
          ></ix-input>

          <ix-input
            formControlName="community"
            [label]="'Community' | translate"
            [tooltip]="tooltips.community | translate"
          ></ix-input>
        </ix-fieldset>

        <ix-fieldset [title]="'SNMP v3 Options' | translate">
          <ix-checkbox
            formControlName="v3"
            [label]="'SNMP v3 Support' | translate"
            [tooltip]="tooltips.v3 | translate"
          ></ix-checkbox>

          @if (isV3SupportEnabled) {
            <ix-input
              formControlName="v3_username"
              [label]="'Username' | translate"
              [tooltip]="tooltips.v3_username | translate"
            ></ix-input>

            <ix-select
              formControlName="v3_authtype"
              emptyValue=""
              [options]="authtypeOptions$"
              [label]="'Authentication Type' | translate"
              [tooltip]="tooltips.v3_authtype | translate"
            ></ix-select>

            <ix-input
              formControlName="v3_password"
              type="password"
              [label]="'Password' | translate"
              [required]="true"
              [tooltip]="tooltips.v3_password | translate"
            ></ix-input>

            <ix-select
              formControlName="v3_privproto"
              [options]="privprotoOptions$"
              [label]="'Privacy Protocol' | translate"
              [tooltip]="tooltips.v3_privproto | translate"
            ></ix-select>

            <ix-input
              formControlName="v3_privpassphrase"
              type="password"
              [label]="'Privacy Passphrase' | translate"
              [tooltip]="tooltips.v3_privpassphrase | translate"
            ></ix-input>
          }
        </ix-fieldset>
      </div>

      <ix-fieldset [title]="'Other Options' | translate">
        <ix-textarea
          formControlName="options"
          [label]="'Auxiliary Parameters' | translate"
          [tooltip]="tooltips.options | translate"
        ></ix-textarea>

        <ix-checkbox
          formControlName="zilstat"
          [label]="'Expose zilstat via SNMP' | translate"
        ></ix-checkbox>

        <ix-select
          formControlName="loglevel"
          [options]="logLevelOptions$"
          [label]="'Log Level' | translate"
          [tooltip]="tooltips.loglevel | translate"
        ></ix-select>
      </ix-fieldset>

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          mat-button
          type="submit"
          color="primary"
          ixTest="save"
          [disabled]="form.invalid || isFormLoading()"
        >
          {{ 'Save' | translate }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
